package com.zhc.tools.demo.service;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhc.tools.demo.domain.ImportOperateInfo;
import com.zhc.tools.demo.domain.ImportOperateInfoQuery;
import com.zhc.tools.demo.manager.ImportOperateInfoManager;
import com.zhc.tools.demo.web.context.ExistedException;
import com.zhc.tools.demo.web.context.PageUtil;
 
/**
 * ImportOperateInfoService接口的实现类
 * 
 * @author zhc
 * 
 */
@Service
public class ImportOperateInfoServiceImpl implements ImportOperateInfoService {

    /** this.logger */
    private final Log logger = LogFactory.getLog(this.getClass());

    @Autowired
    private ImportOperateInfoManager importOperateInfoManager;

    /**
     * {@inheritDoc}
     */
    public boolean insert(List<ImportOperateInfo> importOperateInfoList) {
        boolean resultFlag = false;
        try {
            if (CollectionUtils.isNotEmpty(importOperateInfoList)) {
                resultFlag = importOperateInfoManager.insert(importOperateInfoList);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#batchInsert failed, param is illegal.");
            }
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#batchInsert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public boolean insert(ImportOperateInfo importOperateInfo) {
        boolean resultFlag = false;
        try {
            if (null != importOperateInfo) {
                resultFlag = importOperateInfoManager.insert(importOperateInfo);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#insert failed, param is illegal.");
            }
        } catch (ExistedException e) {
            this.logger.warn("ImportOperateInfoServiceImpl#insert failed, importOperateInfo has existed.");
            throw e;
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#insert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public boolean update(ImportOperateInfo importOperateInfo) {
        boolean resultFlag = false;
        try {
            if (null != importOperateInfo && null != importOperateInfo.getId()) {
                resultFlag = importOperateInfoManager.update(importOperateInfo);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#update failed, param is illegal.");
            }
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#update has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public List<ImportOperateInfo> queryImportOperateInfoList(ImportOperateInfoQuery queryBean) {
        List<ImportOperateInfo> importOperateInfoList = null;
        try {
            importOperateInfoList = importOperateInfoManager.queryImportOperateInfoList(queryBean);
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#queryImportOperateInfoList has error.", e);
        }
        return importOperateInfoList;
    }

    /**
     * {@inheritDoc}
     */
    public List<ImportOperateInfo> queryImportOperateInfoListWithPage(ImportOperateInfoQuery queryBean, PageUtil pageUtil) {
        List<ImportOperateInfo> importOperateInfoList = null;
        try {
            importOperateInfoList = importOperateInfoManager.queryImportOperateInfoListWithPage(queryBean, pageUtil);
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#queryImportOperateInfoListWithPage has error.", e);
        }
        return importOperateInfoList;
    }

    /**
     * {@inheritDoc}
     */
    public boolean delete(ImportOperateInfo importOperateInfo) {
        boolean resultFlag = false;
        try {
            if (null != importOperateInfo && null != importOperateInfo.getId()) {
                resultFlag = importOperateInfoManager.delete(importOperateInfo);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#delete param is illegal.");
            }
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#delete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public boolean delete(ImportOperateInfo[] importOperateInfos) {
        boolean resultFlag = false;
        try {
            if (null != importOperateInfos && importOperateInfos.length > 0) {
                resultFlag = importOperateInfoManager.delete(importOperateInfos);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#batchDelete failed, param is illegal.");
            }
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#batchDelete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public ImportOperateInfo getImportOperateInfoById(Long id) {
        ImportOperateInfo importOperateInfo = null;
        try {
            if (null != id) {
                importOperateInfo = importOperateInfoManager.getImportOperateInfoById(id);
            } else {
                this.logger.warn("ImportOperateInfoServiceImpl#getImportOperateInfoById failed, param is illegal.");
            }
        } catch (Exception e) {
            this.logger.error("ImportOperateInfoServiceImpl#getImportOperateInfoById has error.", e);
        }
        return importOperateInfo;
    }
}

